package ast.nodes.commandNodes;

import scanner.Token;
import scanner.TokenType;
import ast.ASTNode;
import ast.Evaluation;
import ast.nodes.CommandNode;
import ast.nodes.ParameterNode;

public class RemoveNode extends CommandNode {

    public RemoveNode()
    {
        super();
    }
    
    public RemoveNode(Token data)
    {
        super(data);
    }
    
    /**
     * remove(a) removes all occurrences of the character a from LINE.
     */
    @Override
    public void run(Evaluation input) {
        Character a = null;
        for (ASTNode child : children)
        	if(child instanceof ParameterNode)
        		if(child.getData().getType() == TokenType.CHARACTER)
        			if(a == null)
        				a = child.getData().getTokenString().charAt(0);
        input.remove(a);
    }
}
